﻿package org.cshoo.sys.data.dao;

import java.util.List;

import org.cshoo.common.data.dao.BaseDAO;
import org.cshoo.sys.data.entity.Menu;
import org.cshoo.sys.data.idao.IMenuDAO;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

public class MenuDAO extends BaseDAO implements IMenuDAO {

	@Override
	public List findRootMenuList() {
		DetachedCriteria criteria = DetachedCriteria.forClass(Menu.class);
		criteria.add(Restrictions.isNull("parent"));//根据父节点为空的原理查询
		return super.findObjectListByCriteria(criteria);
	}

	@Override
	public List findMenuListByParent(Menu parent) {
		DetachedCriteria criteria = DetachedCriteria.forClass(Menu.class);
		criteria.add(Restrictions.eq("parent",parent));
		return super.findObjectListByCriteria(criteria);
	}

}
